package bravo.xc.com.xc_bravo_android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import bravo.xc.com.xc_bravo_android.R;
import bravo.xc.com.xc_bravo_android.beans.MessageBeans;
import bravo.xc.com.xc_bravo_android.beans.MessageResultBeans;

/**
 * Created by HDL on 2017/10/30.
 */

public class messageListViewAdapter extends BaseAdapter {

    private Context mContext;
    private int resourceId;
    private List<MessageResultBeans.DataBean> dataBeans;

    public messageListViewAdapter(Context context , int textViewResourceId, List<MessageResultBeans.DataBean> objects) {
        super();
        this.mContext=context;
        this.resourceId=textViewResourceId;
        this.dataBeans =objects;
        //initData();
    }

    @Override
    public int getCount() {
        return dataBeans.size();
    }

    @Override
    public MessageResultBeans.DataBean getItem(int position) {
        return dataBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder=new Holder();
        if(convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(R.layout.item_message,null);

            holder.tv_message_msg= (TextView)convertView.findViewById(R.id.tv_message_msg);
            holder.tv_message_time= (TextView) convertView.findViewById(R.id.tv_message_time);

            convertView.setTag(holder);
        }else{
            holder=(Holder)convertView.getTag();
        }
        holder.tv_message_msg.setText("您有一个新订单");
        holder.tv_message_time.setText(dataBeans.get(position).getCreateTime());

        //根据isSelected来设置item的选中情况
        notifyDataSetChanged();
        return convertView;
    }

    class Holder{
        TextView tv_message_time;
        TextView tv_message_msg;
    }

}
